| {% extends "background/base.html" %}
block pagetitle
	| : 书籍搜索 - 纠正最后章节
- block content
	#NAVID(data-nav="booksearch")
	.row
		if success
			.col-xs-12
				.alert.alert-dismissable.alert-success
					button.close(data-dismiss="alert",type="button") ×
					strong 更新成功！
						a(href="{% url 'bbg:book_search' %}") [返回书籍搜索]
		.col-xs-12
			.panel.panel-primary
				.panel-heading 纠正最后章节
				.panel-body
					if books
						table.table
							thead
								tr
									th 书名
									th 作者
									th(style="width:73px;") 分类
									th(style="width:450px;") 章节
									th(style="width:75px;") 更新时间
									th 操作
							tbody
								for book in books
									tr
										td(title=book.book_number)= book.title
											br
											a.btn.btn-xs.btn-success(title=book.title,tabindex="0",role="button",data-toggle="popover",data-trigger="focus",data-content="{{book.info}}") 简介
										td= book.author
										td= book.category
										td
											span 最新：
											a.new(href="{{book.last_page.get_absolute_url}}",target="_blank")= book.last_page.title_html
											br
											span 最后：
											a.last(href="{{book.get_last_page.get_absolute_url}}",target="_blank")= book.get_last_page.title_html
										td= book.last_update|date:"y-m-d"
										td
											a.btn.btn-xs.btn-info.bookjx(href="javascript:;",data-bookid=book.id,title="纠正最新章节",data-toggle="tooltip",data-placement="top") 纠新
					.col-md-12.col-xs-12.text-center
						form(action=".",method="POST")
							| {% csrf_token %}
							a.btn.btn-danger.btn-flat(href="?showall=1") 显示全部
							button.btn.btn-success.btn-flat(type="submit") 全部纠正
							a.btn.btn-link(href="{% url 'bbg:book_search' %}") 返回搜索
					if pagination.has_other_pages
						.col-md-12.col-xs-12.col-sm-12.text-center
							ul.pagination
								if pagination.has_previous
									li
										a(href="#",data-num="1") &lt;&lt;
									li
										a(href="#",data-num="{{pagination.previous_page_number}}") &lt;
								li.active
									span= pagination.number
								if pagination.has_next
									li
										a(href="#",data-num="{{pagination.next_page_number}}") &gt;
									li
										a.fui-arrow-right(href="#",data-num="{{pagination.paginator.num_pages}}") &gt;&gt;
								li.disabled: a(href="javascript:;") 共（{{pagination.paginator.num_pages}}）页，{{pagination.paginator.count}}条数据
block footerjs
	script
		$(function () {
			$('[data-toggle="tooltip"]').tooltip();
			$('[data-toggle="popover"]').popover();
			$('.bookjx').click(function(){
				var bookid = $(this).data('bookid');
				var last_page = $(this).parents('tr').find("span.last").eq(0);
				var new_page = $(this).parents('tr').find("span.new").eq(0);
				$.ajax({
					url: "{% url 'bbg:book_jx' %}",
					method: "POST",
					dataType: 'json',
					data: {book_id:bookid},
					success: function(data){
						new_page.text(last_page.text());
						alert("纠正新章节成功！");
					},
					error: function(xhr,status,error){
						alert("请求失败！Status: "+status+" Content: "+xhr.responseText);
					}
				});
				return false;
			});
		})
